/*
 * Copyright (C) 2015 Daniel Uppenkamp
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.googlecode.maurersmarbles.drawables;

import com.google.common.base.Preconditions;
import com.googlecode.maurersmarbles.Rectangle;
import com.googlecode.maurersmarbles.ScreenCanvas;

/**
 *
 * @author Daniel Uppenkamp
 */
public class MarbleDrawable implements Drawable {

    /**
     * The color of the marble.
     */
    protected int rgb;
    /**
     * The rectangle to draw the marble in.
     */
    protected Rectangle rectangle = new Rectangle();

    /**
     * Creates a new MarbleDrawable.
     *
     * @param rgb the color of the marble
     */
    public MarbleDrawable(int rgb) {
        this.rgb = rgb;
    }

    /**
     * Creates a new MarbleDrawable.
     *
     * @param rgb the color of the marble
     * @param rectangle the rectangle to draw the marble in
     */
    public MarbleDrawable(int rgb, Rectangle rectangle) {
        
        Preconditions.checkNotNull(rectangle, "Null rectangle");
        
        this.rgb = rgb;
        this.rectangle = rectangle;
        
    }

    /**
     * Returns the rectangle to draw the marble in.
     * @return the rectangle to draw the marble in
     */
    public Rectangle getRectangle() {
        return rectangle;
    }
    
    /**
     * Sets the rectangle to draw the marble in.
     *
     * @param rectangle the rectangle to draw the marble in
     */
    public void setRectangle(Rectangle rectangle) {
        Preconditions.checkNotNull(rectangle, "Null rectangle");
        this.rectangle = rectangle;
    }

    @Override
    public void draw(ScreenCanvas screenCanvas) {
        Preconditions.checkNotNull(screenCanvas, "Null screen canvas");
        screenCanvas.drawOval(rectangle, rgb);
    }

}
